﻿//********************************************************************************//
//创建日期：<创建日期，2010-08-02>
//创建作者：<王一飞，wangyifei@shanghai3h.com>
//功能说明：QS_JX_QUXIANBGS实体层次
//********************************************************************************//

#region Entity

using System;
using System.Data;
using Entity;
using Oracle.DataAccess.Client;
using Platform.Configuration;
using Platform.Data;

namespace Entity
{
    [Serializable]
    public class QS_JX_QUXIANBGS
    {
        private decimal? m_dec_i_jlzt;

        private decimal m_dec_id;

        private DateTime? m_DT_d_caozuosj;

        private string m_str_s_caozuor;

        private string m_str_s_fuzer;

        private string m_str_s_fuzerdh;

        private string m_str_s_gongsibh;

        private string m_str_s_gongsidz;

        private string m_str_s_gongsimc;

        private string m_str_s_quxianbh;

        private string m_str_s_xingzhengqbh;

        private string m_str_s_xingzhengqmc;

        private string m_str_s_youbian;

        private string m_str_s_zhibiaor;

        private string m_str_s_zhibiaordh;

        /// <summary>
        ///     主键
        /// </summary>
        public decimal ID
        {
            get { return m_dec_id; }
            set { m_dec_id = value; }
        }

        /// <summary>
        ///     区县编号
        /// </summary>
        public string S_QUXIANBH
        {
            get { return m_str_s_quxianbh; }
            set { m_str_s_quxianbh = value; }
        }

        /// <summary>
        ///     行政区编号
        /// </summary>
        public string S_XINGZHENGQBH
        {
            get { return m_str_s_xingzhengqbh; }
            set { m_str_s_xingzhengqbh = value; }
        }

        /// <summary>
        ///     行政区名称
        /// </summary>
        public string S_XINGZHENGQMC
        {
            get { return m_str_s_xingzhengqmc; }
            set { m_str_s_xingzhengqmc = value; }
        }

        /// <summary>
        ///     公司编号
        /// </summary>
        public string S_GONGSIBH
        {
            get { return m_str_s_gongsibh; }
            set { m_str_s_gongsibh = value; }
        }

        /// <summary>
        ///     公司名称
        /// </summary>
        public string S_GONGSIMC
        {
            get { return m_str_s_gongsimc; }
            set { m_str_s_gongsimc = value; }
        }

        /// <summary>
        ///     公司地址
        /// </summary>
        public string S_GONGSIDZ
        {
            get { return m_str_s_gongsidz; }
            set { m_str_s_gongsidz = value; }
        }

        /// <summary>
        ///     邮编
        /// </summary>
        public string S_YOUBIAN
        {
            get { return m_str_s_youbian; }
            set { m_str_s_youbian = value; }
        }

        /// <summary>
        ///     制表人
        /// </summary>
        public string S_ZHIBIAOR
        {
            get { return m_str_s_zhibiaor; }
            set { m_str_s_zhibiaor = value; }
        }

        /// <summary>
        ///     制表人电话
        /// </summary>
        public string S_ZHIBIAORDH
        {
            get { return m_str_s_zhibiaordh; }
            set { m_str_s_zhibiaordh = value; }
        }

        /// <summary>
        ///     负责人
        /// </summary>
        public string S_FUZER
        {
            get { return m_str_s_fuzer; }
            set { m_str_s_fuzer = value; }
        }

        /// <summary>
        ///     负责人电话
        /// </summary>
        public string S_FUZERDH
        {
            get { return m_str_s_fuzerdh; }
            set { m_str_s_fuzerdh = value; }
        }

        /// <summary>
        ///     记录状态
        /// </summary>
        public decimal? I_JLZT
        {
            get { return m_dec_i_jlzt; }
            set { m_dec_i_jlzt = value; }
        }

        /// <summary>
        ///     操作人
        /// </summary>
        public string S_CAOZUOR
        {
            get { return m_str_s_caozuor; }
            set { m_str_s_caozuor = value; }
        }

        /// <summary>
        ///     操作时间
        /// </summary>
        public DateTime? D_CAOZUOSJ
        {
            get { return m_DT_d_caozuosj; }
            set { m_DT_d_caozuosj = value; }
        }
    }
}

#endregion

#region EntityProcess

namespace BLL.Access
{
    //using System.Data.OracleClient;

    public class QS_JX_QUXIANBGSProcess
    {
        #region Field

        protected string conn;

        #endregion

        #region Construction

        public QS_JX_QUXIANBGSProcess()
        {
            conn = ConfigHelper.PlatformConnString;
        }

        #endregion

        #region public

        /// <summary>
        ///     根据QS_JX_QUXIANBGS实体添加或者修改QS_JX_QUXIANBGS信息
        /// </summary>
        public bool InsertOrUpdate(QS_JX_QUXIANBGS QS_JX_QUXIANBGS, OracleTransaction Transaction)
        {
            if (QS_JX_QUXIANBGS.ID == 0)
                InsertQS_JX_QUXIANBG(QS_JX_QUXIANBGS, Transaction);
            else
                UpdateQS_JX_QUXIANBG(QS_JX_QUXIANBGS, Transaction);
            return QS_JX_QUXIANBGS.ID == 0 ? false : true;
        }

        /// <summary>
        ///     根据QS_JX_QUXIANBGS实体添加或修改QS_JX_QUXIANBGS信息
        /// </summary>
        public bool InsertOrUpdate(QS_JX_QUXIANBGS QS_JX_QUXIANBGS)
        {
            return InsertOrUpdate(QS_JX_QUXIANBGS, null);
        }


        /// <summary>
        ///     根据QS_JX_QUXIANBGS主键删除QS_JX_QUXIANBGS信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteQS_JX_QUXIANBG(decimal ID, OracleTransaction Transaction)
        {
            var spName = "CS_DelQS_JX_QUXIANBG";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            var result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery(Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        ///     根据QS_JX_QUXIANBGS主键删除QS_JX_QUXIANBGS信息
        /// </summary>
        /// <param name="ID"></param>
        public bool DeleteQS_JX_QUXIANBG(decimal ID)
        {
            return DeleteQS_JX_QUXIANBG(ID, null);
        }

        /// <summary>
        ///     根据条件删除QS_JX_QUXIANBGS信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteQS_JX_QUXIANBGsDynamic(string WhereClause, OracleTransaction Transaction)
        {
            var spName = "CS_DelQS_JX_QUXIANBGsDyn";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = WhereClause;
            var result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery(Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }

        /// <summary>
        ///     根据条件删除QS_JX_QUXIANBGS信息
        /// </summary>
        /// <param name="WhereClause">条件子句(Oracle语句)不带where</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>如果删除成功，返回true,否则返回fals</returns>
        public bool DeleteQS_JX_QUXIANBGsDynamic(string WhereClause)
        {
            return DeleteQS_JX_QUXIANBGsDynamic(WhereClause, null);
        }

        /// <summary>
        ///     根据QS_JX_QUXIANBGS主键选择QS_JX_QUXIANBGS信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>QS_JX_QUXIANBGS信息</returns>
        public QS_JX_QUXIANBGS SelectQS_JX_QUXIANBG(decimal ID, OracleTransaction Transaction)
        {
            var spName = "CS_SelQS_JX_QUXIANBG";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = ID;
            OracleDataReader rd;
            if (Transaction == null)
                rd = OracleHelper.ExecuteReader(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                rd = OracleHelper.ExecuteReader(Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (rd.Read())
            {
                var QS_JX_QUXIANBGS = PopulateQS_JX_QUXIANBGS(rd);
                rd.Close();
                return QS_JX_QUXIANBGS;
            }
            return null;
        }

        /// <summary>
        ///     根据QS_JX_QUXIANBGS主键选择QS_JX_QUXIANBGS信息
        /// </summary>
        /// <returns>QS_JX_QUXIANBGS信息</returns>
        public QS_JX_QUXIANBGS SelectQS_JX_QUXIANBG(decimal ID)
        {
            return SelectQS_JX_QUXIANBG(ID, null);
        }

        /// <summary>
        ///     选择所有QS_JX_QUXIANBGS信息
        /// </summary>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>所有QS_JX_QUXIANBGS信息</returns>
        public DataTable SelectQS_JX_QUXIANBGsAll(OracleTransaction Transaction)
        {
            var spName = "CS_SelQS_JX_QUXIANBGsAll";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset(Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            return null;
        }

        /// <summary>
        ///     选择所有QS_JX_QUXIANBGS信息
        /// </summary>
        /// <returns>所有QS_JX_QUXIANBGS信息</returns>
        public DataTable SelectQS_JX_QUXIANBGsAll()
        {
            return SelectQS_JX_QUXIANBGsAll(null);
        }

        /// <summary>
        ///     根据条件选择QS_JX_QUXIANBGS信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>QS_JX_QUXIANBGS信息</returns>
        public DataTable SelectQS_JX_QUXIANBGsDynamic(string WhereClause, string OrderByExpression,
            OracleTransaction Transaction)
        {
            var spName = "CS_SelQS_JX_QUXIANBGsDyn";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset(Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            return null;
        }


        /// <summary>
        ///     根据条件选择QS_JX_QUXIANBGS信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <returns>QS_JX_QUXIANBGS信息</returns>
        public DataTable SelectQS_JX_QUXIANBGsDynamic(string WhereClause, string OrderByExpression)
        {
            return SelectQS_JX_QUXIANBGsDynamic(WhereClause, OrderByExpression, null);
        }


        /// <summary>
        ///     根据条件选择QS_JX_QUXIANBGS信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <param name="Transaction">事务，如果为null,则不做事务</param>
        /// <returns>QS_JX_QUXIANBGS信息</returns>
        public DataTable SelectQS_JX_QUXIANBGsDynamic(string WhereClause, string OrderByExpression, int PageIndex,
            int PageSize, OracleTransaction Transaction)
        {
            var spName = "CS_SelQS_JX_QUXIANBGsDynPaged";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = string.IsNullOrEmpty(WhereClause.Trim()) ? "1=1" : WhereClause;
            storedParams[1].Value = OrderByExpression;
            storedParams[2].Value = PageIndex;
            storedParams[3].Value = PageSize;
            DataSet ds = null;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset(Transaction, CommandType.StoredProcedure, spName, storedParams);
            if (ds != null && ds.Tables.Count > 0)
            {
                AddRowNumber(ds.Tables[0]);
                return ds.Tables[0];
            }
            return null;
        }


        /// <summary>
        ///     根据条件选择QS_JX_QUXIANBGS信息
        /// </summary>
        /// <param name="WhereClause">条件子句(不带where)</param>
        /// <param name="OrderByExpression">排序子句</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageSize">页数</param>
        /// <returns>QS_JX_QUXIANBGS信息</returns>
        public DataTable SelectQS_JX_QUXIANBGsDynamic(string WhereClause, string OrderByExpression, int PageIndex,
            int PageSize)
        {
            return SelectQS_JX_QUXIANBGsDynamic(WhereClause, OrderByExpression, PageIndex, PageSize, null);
        }

        /// <summary>
        ///     根据条件更新QS_JX_QUXIANBGS字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateQS_JX_QUXIANBGsDynamic(string UpdateValue, string WhereClause, OracleTransaction Transaction)
        {
            var result = 0;
            if (UpdateValue == "" || WhereClause == "")
                return 0;
            var spName = "CS_UpdQS_JX_QUXIANBGDyn";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            DataSet ds = null;
            storedParams[0].Value = UpdateValue;
            storedParams[1].Value = WhereClause;
            if (Transaction == null)
                ds = OracleHelper.ExecuteDataset(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                ds = OracleHelper.ExecuteDataset(Transaction, CommandType.StoredProcedure, spName, storedParams);
            result = Convert.ToInt32(storedParams[2].Value);
            return result;
        }

        /// <summary>
        ///     根据条件更新QS_JX_QUXIANBGS字段
        /// </summary>
        /// <returns>受影响行数</returns>
        public int UpdateQS_JX_QUXIANBGsDynamic(string UpdateValue, string WhereClause)
        {
            return UpdateQS_JX_QUXIANBGsDynamic(UpdateValue, WhereClause, null);
        }

        #endregion

        #region Private

        private int InsertQS_JX_QUXIANBG(QS_JX_QUXIANBGS QS_JX_QUXIANBGS, OracleTransaction Transaction)
        {
            var spName = "CS_InsQS_JX_QUXIANBGS";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = QS_JX_QUXIANBGS.S_QUXIANBH;
            storedParams[1].Value = QS_JX_QUXIANBGS.S_XINGZHENGQBH;
            storedParams[2].Value = QS_JX_QUXIANBGS.S_XINGZHENGQMC;
            storedParams[3].Value = QS_JX_QUXIANBGS.S_GONGSIBH;
            storedParams[4].Value = QS_JX_QUXIANBGS.S_GONGSIMC;
            storedParams[5].Value = QS_JX_QUXIANBGS.S_GONGSIDZ;
            storedParams[6].Value = QS_JX_QUXIANBGS.S_YOUBIAN;
            storedParams[7].Value = QS_JX_QUXIANBGS.S_ZHIBIAOR;
            storedParams[8].Value = QS_JX_QUXIANBGS.S_ZHIBIAORDH;
            storedParams[9].Value = QS_JX_QUXIANBGS.S_FUZER;
            storedParams[10].Value = QS_JX_QUXIANBGS.S_FUZERDH;
            storedParams[11].Value = QS_JX_QUXIANBGS.I_JLZT;
            storedParams[12].Value = QS_JX_QUXIANBGS.S_CAOZUOR;
            storedParams[13].Value = QS_JX_QUXIANBGS.D_CAOZUOSJ;
            var result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery(Transaction, CommandType.StoredProcedure, spName, storedParams);
            QS_JX_QUXIANBGS.ID = Convert.ToInt32(storedParams[14].Value);
            return result;
        }

        private bool UpdateQS_JX_QUXIANBG(QS_JX_QUXIANBGS QS_JX_QUXIANBGS, OracleTransaction Transaction)
        {
            var spName = "CS_UpdQS_JX_QUXIANBG";
            var storedParams = OracleHelperParameterCache.GetSpParameterSet(conn, spName);
            storedParams[0].Value = QS_JX_QUXIANBGS.S_QUXIANBH;
            storedParams[1].Value = QS_JX_QUXIANBGS.S_XINGZHENGQBH;
            storedParams[2].Value = QS_JX_QUXIANBGS.S_XINGZHENGQMC;
            storedParams[3].Value = QS_JX_QUXIANBGS.S_GONGSIBH;
            storedParams[4].Value = QS_JX_QUXIANBGS.S_GONGSIMC;
            storedParams[5].Value = QS_JX_QUXIANBGS.S_GONGSIDZ;
            storedParams[6].Value = QS_JX_QUXIANBGS.S_YOUBIAN;
            storedParams[7].Value = QS_JX_QUXIANBGS.S_ZHIBIAOR;
            storedParams[8].Value = QS_JX_QUXIANBGS.S_ZHIBIAORDH;
            storedParams[9].Value = QS_JX_QUXIANBGS.S_FUZER;
            storedParams[10].Value = QS_JX_QUXIANBGS.S_FUZERDH;
            storedParams[11].Value = QS_JX_QUXIANBGS.I_JLZT;
            storedParams[12].Value = QS_JX_QUXIANBGS.S_CAOZUOR;
            storedParams[13].Value = QS_JX_QUXIANBGS.D_CAOZUOSJ;
            storedParams[14].Value = QS_JX_QUXIANBGS.ID;
            var result = 0;
            if (Transaction == null)
                result = OracleHelper.ExecuteNonQuery(conn, CommandType.StoredProcedure, spName, storedParams);
            else
                result = OracleHelper.ExecuteNonQuery(Transaction, CommandType.StoredProcedure, spName, storedParams);
            return result == 0 ? false : true;
        }


        private QS_JX_QUXIANBGS PopulateQS_JX_QUXIANBGS(IDataReader dr)
        {
            var QS_JX_QUXIANBGS = new QS_JX_QUXIANBGS();
            QS_JX_QUXIANBGS.ID = dr["ID"] == DBNull.Value ? 0 : (decimal) dr["ID"];
            QS_JX_QUXIANBGS.S_QUXIANBH = dr["S_QUXIANBH"] == DBNull.Value ? null : (string) dr["S_QUXIANBH"];
            QS_JX_QUXIANBGS.S_XINGZHENGQBH =
                dr["S_XINGZHENGQBH"] == DBNull.Value ? null : (string) dr["S_XINGZHENGQBH"];
            QS_JX_QUXIANBGS.S_XINGZHENGQMC =
                dr["S_XINGZHENGQMC"] == DBNull.Value ? null : (string) dr["S_XINGZHENGQMC"];
            QS_JX_QUXIANBGS.S_GONGSIBH = dr["S_GONGSIBH"] == DBNull.Value ? null : (string) dr["S_GONGSIBH"];
            QS_JX_QUXIANBGS.S_GONGSIMC = dr["S_GONGSIMC"] == DBNull.Value ? null : (string) dr["S_GONGSIMC"];
            QS_JX_QUXIANBGS.S_GONGSIDZ = dr["S_GONGSIDZ"] == DBNull.Value ? null : (string) dr["S_GONGSIDZ"];
            QS_JX_QUXIANBGS.S_YOUBIAN = dr["S_YOUBIAN"] == DBNull.Value ? null : (string) dr["S_YOUBIAN"];
            QS_JX_QUXIANBGS.S_ZHIBIAOR = dr["S_ZHIBIAOR"] == DBNull.Value ? null : (string) dr["S_ZHIBIAOR"];
            QS_JX_QUXIANBGS.S_ZHIBIAORDH = dr["S_ZHIBIAORDH"] == DBNull.Value ? null : (string) dr["S_ZHIBIAORDH"];
            QS_JX_QUXIANBGS.S_FUZER = dr["S_FUZER"] == DBNull.Value ? null : (string) dr["S_FUZER"];
            QS_JX_QUXIANBGS.S_FUZERDH = dr["S_FUZERDH"] == DBNull.Value ? null : (string) dr["S_FUZERDH"];
            QS_JX_QUXIANBGS.I_JLZT = dr["I_JLZT"] == DBNull.Value ? null : (decimal?) dr["I_JLZT"];
            QS_JX_QUXIANBGS.S_CAOZUOR = dr["S_CAOZUOR"] == DBNull.Value ? null : (string) dr["S_CAOZUOR"];
            QS_JX_QUXIANBGS.D_CAOZUOSJ = dr["D_CAOZUOSJ"] == DBNull.Value ? null : (DateTime?) dr["D_CAOZUOSJ"];
            return QS_JX_QUXIANBGS;
        }


        private void AddRowNumber(DataTable dt)
        {
            dt.Columns.Add(new DataColumn("RowNumber", typeof(int)));
            for (var i = 0; i < dt.Rows.Count; i++)
                dt.Rows[i][dt.Columns.Count - 1] = i + 1;
        }

        #endregion
    }
}

#endregion